<template>
  <div>
    <p>我是全局组件</p>
    <p>传进来的值value：{{ value }}</p>
    <p>传进来的值name：{{ name }}</p>
    <p>传进来的值published：{{ published }}</p>
    <p>传进来的值commentIds：{{ commentIds }}</p>
    <p>传进来的值author：{{ author }}</p>
    <div>
      <el-button type="primary" size="small" @click="handEmit">向父元素传值</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'global-com'
}
</script>
<script setup>

const props = defineProps({
  value: {
    type: Number,
    default: 0
  },
  name: {
    type: String,
    default: ''
  },
  published: {
    type: Boolean,
    default: true
  },
  commentIds: {
    type: Array,
    default: () => []
  },
  author: {
    type: Object,
    default: () => ({})
  }
})

const emit = defineEmits(['getValue'])
const handEmit = () => {
  console.log('value: ', props.value);
  emit('getValue', props.value + 1)
}
</script>
<style lang="scss" scoped>

</style>
